<?php
/**
 * Users_ProfileController
 *
 * @category Users
 * @package  Users_ProfileController
 * @version  $Id$
 */
class Users_ProfileController extends Lizard_Core_Controller_Action
{
    /**
     * Index
     *
     * @see Lizard_Controller_Action_Category::indexAction()
     */
    public function indexAction()
    {
        $userId = Zend_Auth::getInstance()->getIdentity()->id;
        if ($row = $this->getTable()->findRow($userId)) {

            $form = $this->getForm('Profile');
            if ($this->_request->isPost()
                && $form->isValid($this->_getAllParams())) {

                $row->setFromArray($form->getValues());
                $row->save();

                $alert = new Lizard_Alert_Type_Success();
                $alert->message = 'Profile updates successfully';
                $alert->save();
            }
            $this->view->form = $form;
        } else {
            throw new Lizard_Controller_Action_Exception('Page not found');
        }
    }
}